package main

import (
	"sync"
	"fmt"
	"runtime"
)

func main(){
	out_test4()
}

func out_test1(){
	runtime.GOMAXPROCS(1)
	wg := sync.WaitGroup{}
	wg.Add(30)
	for i := 0; i < 10; i++ {
		go func() {
			fmt.Println("i: ", i)
			wg.Done()
		}()
	}
	for i := 0; i < 10; i++ {
		go func(i int) {
			fmt.Println("i2: ", i)
			wg.Done()
		}(i)
	}

	for i := 10; i < 20; i++ {
		go func(i int) {
			fmt.Println("i3: ", i)
			wg.Done()
		}(i)
	}
	wg.Wait()
}

func out_test2(){
	m := make(map[string]int,10)
	s :=&UserAges{ages:m}
	s.Add("sss",2)
	s.Get("sss")
}

type UserAges struct {
	ages map[string]int
	sync.Mutex
}

func (ua *UserAges) Add(name string, age int) {
	ua.Lock()
	defer ua.Unlock()
	ua.ages[name] = age
}

func (ua *UserAges) Get(name string) int {
	if age, ok := ua.ages[name]; ok {
		return age
	}
	return -1
}



type People interface {
	Speak(string) string
}

type Stduent struct{}

func (stu *Stduent) Speak(think string) (talk string) {
	if think == "bitch" {
		talk = "You are a good boy"
	} else {
		talk = "hi"
	}
	return
}

func out_test3() {
	var peo  People= &Stduent{}
	think := "bitch"
	fmt.Println(peo.Speak(think))
}

type People1 interface {
	Show()
}

type Student struct{}

func (stu *Student) Show() {

}
func live() People1 {
	var stu *Student
	return stu
}

func out_test4() {
	if live() == nil {
		fmt.Println("AAAAAAA")
	} else {
		var s *UserAges
		fmt.Println(s)
		fmt.Println(s ==nil)
		fmt.Println(live())
		fmt.Println(live()==nil)
		fmt.Println("BBBBBBB")
	}
}